import API from "@utils/request";

// const URL = "192.168.2.160:8010";

const SYSTEM_USER = "/system/customer"; //患者

/**
 * 患者管理列表
 */
export async function getPatientList(params) {
  // console.log("患者页面，分页", params);
  try {
    return await API.get(SYSTEM_USER + "/list", {
      params,
    });
  } catch (error) {
    return error;
  }
}

/**
 * 获取已有患者姓名首字母
 */
export async function getFirstLetter(params) {
  try {
    return await API.get(SYSTEM_USER + "/getFirstLetter", {
      params,
    });
  } catch (error) {
    return error;
  }
}

/**
 * 验证客户信息
 */
export async function verifyByCode(params) {
  try {
    return await API.post(SYSTEM_USER + "/verifyByCode", params);
  } catch (error) {
    return error;
  }
}

/**
 * 存档（手动录入）
 */
export async function saveCheckResult(params) {
  try {
    return await API.post(SYSTEM_USER + "/saveCheckResult", params);
  } catch (error) {
    return error;
  }
}

/**
 * 删除档案
 */
export async function remove(params) {
  try {
    return await API.post(SYSTEM_USER + "/remove/" + params);
  } catch (error) {
    return error;
  }
}

/**
 * 查看档案
 */
export async function patientInfo(params) {
  console.log("查看档案", params);
  try {
    return await API.post(SYSTEM_USER + params);
  } catch (error) {
    return error;
  }
}

/**
 * 查看单个患者信息
 */
export async function patientInfoById(params) {
  console.log("查看单个患者信息", params);
  try {
    return await API.get(SYSTEM_USER + "/" + params);
  } catch (error) {
    return error;
  }
}

/**
 * 结果导出
 */
export async function patientInfoExport(params, code) {
  console.log("结果导出", params, code);
  try {
    return await API.post(
      SYSTEM_USER + "/export/" + params,
      {},
      {
        fileName: code + '.xls',
        responseType: "blob",
      }
    );
  } catch (error) {
    return error;
  }
}
/**
 * 批量导出
 */
export async function patientInfoBatchExport(params) {
  // console.log("结果导出", params);
  // console.log(params.name);
  try {
    return await API.post(SYSTEM_USER + "/export/", params.recordIds, {
      // headers: {
      //   "Content-Type": "application/json;"
      // },
      fileName: params.name,
      responseType: "blob",
    });
  } catch (error) {
    return error;
  }
}
